--  --------------------------------------------------------------------------
--  @File:        html_writer.ads
--
--  @Project:     HTML_Writer
--  @Version:     1.1
--  @Created:     2011-12-06
--  @Author:  Benedikt Markt, Aleksander Zotov, Marcel Kranz
--
--  @Description: Creates a HTML file.
--
--  @Modifications:
--    +2011-12-06 BM, AZ, MKR: Added checkpoints for correct HTML syntax.

with Ada.Text_IO, Ada.Strings.Fixed, Ada.Strings;
use  Ada.Text_IO;

package HTML_Writer is

   --  -----------------------------------------------------------------------
   --  @Type: HTML_Writer_Record_Type
   type HTML_Writer_Record_Type;

   --  -----------------------------------------------------------------------
   --  @Type: State_Type
   type State_Type is
     (PAGE_STARTED, HEAD_WRITTEN, BODY_STARTED,
      LIST_STARTED, ITEM_STARTED, BODY_FINISHED);

   --  -----------------------------------------------------------------------
   --  @Type: HTML_Writer_Type
   type HTML_Writer_Type is access HTML_Writer_Record_Type;

   type HTML_Writer_Record_Type is record
      File : Ada.Text_IO.File_Type;
      State : State_Type;
   end record;

   --  -----------------------------------------------------------------------
   --  @Exception: Illegal_State_Exception
   Illegal_State_Exception : exception;

   --  -----------------------------------------------------------------------
   --  @Function: Initialize
   --
   --  @Description: Creates a file
   --  @Parameter:
   --    +File_Name: Name of a file to create
   --
   --  @Return: Pointer to created file
   function Initialize (File_Name : String) return HTML_Writer_Type;

   --  -----------------------------------------------------------------------
   --  @Procedure: Start_Page
   --
   --  @Description: Add <html> tag to the file
   --  @Parameter:
   --    +File: The file to edit.
   procedure Start_Page (HTML_File : in HTML_Writer_Type);

   --  -----------------------------------------------------------------------
   --  @Procedure: Finish_Page
   --
   --  @Description: Add  </html> tag to end the file.
   --  @Parameter:
   --    +File: The file to edit.
   procedure Finish_Page (HTML_File : in HTML_Writer_Type);

   --  -----------------------------------------------------------------------
   --  @Procedure: Write_Head
   --
   --  @Description: Creates and order the header of the html document.
   --  @Parameter:
   --    +File: The file to edit.
   --    +Title The title of the html document.
   procedure Write_Head (HTML_File : in HTML_Writer_Type; Title : in String);

   --  -----------------------------------------------------------------------
   --  @Procedure: Start_Body
   --
   --  @Description: Body of the html page is implemented.
   --  @Parameter:
   --    +File: The file to edit.
   procedure Start_Body (HTML_File : in HTML_Writer_Type);

   --  -----------------------------------------------------------------------
   --  @Procedure: Finish_Body
   --
   --  @Description: Close a </body> tag.
   --  @Parameter:
   --    +File: The file to edit.
   procedure Finish_Body (HTML_File : in HTML_Writer_Type);

   --  -----------------------------------------------------------------------
   --  @Procedure: Write_Heading
   --
   --  @Description: Writes the headlines with given level to the html file.
   --  @Parameter:
   --    +File: The file to edit.
   --    +Text: The text of the heading.
   --    +Level: The level of the heading.
   procedure Write_Heading
     (HTML_File : in HTML_Writer_Type;
      Text      : in String;
      Level     : in Positive);

   --  -----------------------------------------------------------------------
   --  @Procedure: Add_Paragraph
   --
   --  @Description: Adds a line by writing to the page.
   --  @Parameter:
   --    +File: The file to edit.
   --    +Text: The text to add to the file.
   procedure Add_Paragraph (HTML_File : in HTML_Writer_Type; Text : in String);

   --  -----------------------------------------------------------------------
   --  @Procedure: Start_List
   --
   --  @Description: Start an unordered list by writing a <ul> tag.
   --  @Parameter:
   --    +File: The file to edit.
   procedure Start_List (HTML_File : in HTML_Writer_Type);

   --  -----------------------------------------------------------------------
   --  @Procedure: Finish_List
   --
   --  @Description: Finish an unordered list by writing </ul> tag.
   --  @Parameter:
   --    +File: The file to edit.
   procedure Finish_List (HTML_File : in HTML_Writer_Type);

   --  -----------------------------------------------------------------------
   --  @Procedure: Start_List_Item
   --
   --  @Description: Start a new list item by writing <li>.
   --  @Parameter:
   --    +File: The file to edit.
   procedure Start_List_Item (HTML_File : in HTML_Writer_Type);

   --  -----------------------------------------------------------------------
   --  @Procedure: Finish_List_Item
   --
   --  @Description: Finish a list item by writing </li>.
   --  @Parameter:
   --    +File: The file to edit.
   procedure Finish_List_Item (HTML_File : in HTML_Writer_Type);

   --  -----------------------------------------------------------------------
   --  @Procedure: Add_Link
   --
   --  @Description: Adds a link.
   --  @Parameter:
   --    +File: The file to edit.
   --    +Target: Target of the link.
   --    +Text: Link text
   procedure Add_Link
     (HTML_File : in HTML_Writer_Type;
      Target    : in String;
      Text      : in String);

   --  -----------------------------------------------------------------------
   --  @Procedure: Add_Text
   --
   --  @Description: Add text  to the HTML document.
   --  @Parameter:
   --    +File: The file to edit.
   --    +Text: The text to add to rhe file
   procedure Add_Text (HTML_File : in HTML_Writer_Type; Text : in String);

end HTML_Writer;
